const mixin = {
	computed: {
		// 处理时间(活动时间)
		dateFormat(startTime, endTime) {
			return (startTime, endTime) => {
				var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
				var d = new Date(startTime.split('T')[0]);
				var start_time = startTime.split('T')[1].substr(0, 5)
				var end_time = endTime.split('T')[1].substr(0, 5)
				// parseInt去0
				var month = parseInt(startTime.split('-')[1])
				var day = parseInt(startTime.split('-')[2].substr(0, 2))
				var newDate = `${month}月${day}日 ${weekDay[d.getDay()]} ${start_time}-${end_time}`;
				return newDate;
			}
		},
		// 处理时间(截止报名时间)
		dateFormat1(date) {
			return date => {
				var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
				var d = new Date(date.split('T')[0]);
				var time = date.split('T')[1].substr(0, 5)
				var month = parseInt(date.split('-')[1])
				var day = parseInt(date.split('-')[2].substr(0, 2))
				var newDate = `${month}月${day}日 ${weekDay[d.getDay()]} ${time}`;
				return newDate;
			}
		},
		// 处理按钮显示
		checkActivity(num, status) {
			return (num, status) => {
				var state = 0
				var result = ''
				// status:0未开始,1进行中,2已结束
				switch (status) {
					case '0':
						state = 0
						if (num == 0) {
							result = '马上报名'
						} else {
							result = num + '人已报名'
						}
						break;
					case '1':
						state = 1
						result = '活动进行中'
						break;
					case '2':
						state = 2
						result = '活动已结束'
						break;
					default:
						console.log('出错了')
						break;
				}
				return result
			}
		}
	}
}
export default mixin;
